/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tdtest.controls;

import javafx.scene.layout.VBox;
import tdtest.controls.factory.EventControlFactory;
import tdtest.data.*;

/**
 *
 * @author sutter
 */
public class ActionControl extends SystemComponentControl<TDAction> {
	
	private ControlList<TDEvent> eventList;
	private FunctionControl functionControl;
	private VBox content;
	
	public ActionControl(TDAction action) {
		super(action);
		this.getStyleClass().add("action-control");
		init(action);
	}
	
	private void init(TDAction action) {

		content = new VBox();
		
		eventList = new ControlList<>(action.events, new EventControlFactory());
		eventList.getStyleClass().add("action-event-list");
		content.getChildren().add(eventList);
		
		if(action.function != null) {
			functionControl = new FunctionControl(action.function);
			functionControl.getStyleClass().add("action-function");
			content.getChildren().add(functionControl);
		}
		
		content.getStyleClass().add("action-content");
		
		this.setContent(content);
	}
}
